<?php
/**
 * Created by PhpStorm.
 * User: 王新宇
 * Date: 2021/11/9
 * Time: 15:19
 */

namespace app\admin\controller;

use app\admin\model\Brand;
use app\admin\model\Category;
use think\facade\Request;
use think\facade\View;


class goods
{
    public function good_list()
    {
        $where=[];

$post=Request::param();

View::assign($post);

if (isset($post['keywords']) && $post['keywords'] <> '')
    $where['keywords']=$post['keywords']; //$where[]=['a.name','like',"%{$post['keywords']}%"];
if (isset($post['is_down']) && count($post['is_down'])==1) //$where[]=['a.is_down','in',$post['is_down']];
    $where['is_down'] = $post['is_down'];
if (isset($post['is_show']) && $post['is_show'] <> '')     //$where[]=['a.is_show','=',$post['is_show']];
    $where['is_show']=$post['is_show'];
if (isset($post['is_hot']) && $post['is_hot'] <> '')       //$where[]=['a.is_hot','=',$post['is_hot']];
        $where['is_hot']=$post['is_hot'];
if (isset($post['cid']) && $post['cid'] <> '')             //$where[]=['a.cid','=',$post['cid']];
    $where['cid']=$post['cid'];
if (isset($post['price']) && $post['price'] <> '')         $where[]=['a.price','between',$post['price']];
if (isset($post['time']) && $post['time'] <> '')           $where[]=['a.addtime','between time',$post['time']];

         $list = \app\admin\model\Goods::getGoodsList($where);
        View::assign('list',$list);
          $arr =  Category::getCategory();
        View::assign('arr',$arr);
        return view();

   }

   //品牌列表
    public function brand_list()
    {
        $where = [];
        $post=Request::param();
        View::assign($post);
        if(isset($post['keywords']) && $post['keywords'] <> '')
            $where['keywords'] = $post['keywords'];
        if(isset($post['if_show']) && $post['if_show'] <> '')
            $where['if_show'] = $post['if_show'];
        if(isset($post['recommended']) && $post['recommended'] <> '')
            $where['recommended'] = $post['recommended'];
        if(isset($post['tu']) && $post['tu'] <> '')
            $where['tu'] = $post['tu'];
        if(isset($post['wtu']) && $post['wtu'] <> '')
            $where['wtu'] = $post['wtu'];
       $list =  Brand::getBrandList($where);
        View::assign('list',$list);
        return view();
    }
}